<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>候选人列表</title>
	<link rel="stylesheet" href="../css/bootstrap.min.css" />
	<style type="text/css">
		body{
			background-image: url("../img/batthern.png");
		}
		
		.table td, .table th{
			text-align: center;
		}
	</style>
</head>
<body>
	<%@ include file="include/top.jsp" %>

	<div class="container" style="margin-top: 60px;">
		<div class="row">
			<jsp:include page="include/left.jsp">
				<jsp:param value="candidatelist" name="tag"/>
			</jsp:include>
			<div class="span9">
				<div class="wall" style="min-height: 400px;" id="right">
					<h3>候选人列表</h3>
					<hr />
			    <table class="table table-striped" style="font-size: 12px;">
				    <thead>
					    <tr style="text-align: center">
						    <th>学号</th>
						    <th>姓名</th>
						    <th>性别</th>
						    <th>民族</th>
						    <th>政治面貌</th>
						    <th>学院</th>
						    <th>专业班级</th>
						    <th>操作</th>
					    </tr>
				    </thead>
				    <tbody>
					    <s:iterator value="candidatelist" var="c">
					    	<tr>
							    <td><a href="seenews.jspx?id=<s:property value='#c.id'/>" target="_blank"><s:property value="#c.studentid"/></a></td>
							    <td><s:property value="#c.name"/></td>
							    <td><s:property value="#c.sex == 1 ? '男' : '女 '"/></td>
							    <td><s:property value="#c.nation"/></td>
							    <td>
							    	<s:if test="#c.politics == 1">
							    		党员
							    	</s:if>
							    	<s:elseif test="#c.politics == 2">
							    		预备党员
							    	</s:elseif>
							    	<s:elseif test="#c.politics == 3">
							    		团员
							    	</s:elseif>
							    	<s:else>
							    		其他
							    	</s:else>
							    </td>
							    <td><s:property value="#c.college"/></td>
							    <td><s:property value="#c.major"/></td>
							    <td><a class="btn btn-mini btn-primary" href="editcandidate.jspx?id=<s:property value='#c.id'/>">修改</a>
							    <a class="btn btn-mini btn-warning" href="javascript:;" rel="<s:property value='#c.id'/>" ref="<s:property value='#c.enable'/>">
							    	<s:if test="#c.enable">
							    		禁用
							    	</s:if>
							    	<s:else>
							    		启用
							    	</s:else>
							    </a></td>
						    </tr>
					    </s:iterator>
				    </tbody>
			    </table>
				</div>
			</div>
		</div>
		<%@ include file="include/footer.jsp" %>	
	</div>
	<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../js/welcome.js"></script>
	<script type="text/javascript">
		$(function() {
			$.welcome($("#welcome"));
			
			$("a[rel]").click(function() {
				var curra = $(this);
				var id = $(this).attr("rel").trim();
				var flag = $(this).attr("ref").trim();
				
				if(id != "" && flag != "") {
					$.ajax({
						url : 'candidateenable.jspx',
						type : 'POST',
						data : {
							id : id
						},
						success : function(msg) {
							if(msg == 1) {
								if(flag == "true") {
									curra.text("启用").removeClass("btn-warning").addClass("btn-danger").attr("ref", "false");
								} else {
									curra.text("禁用").removeClass("btn-warning").addClass("btn-danger").attr("ref", "true");
								}
							} else {
								alert("服务器忙，请稍后再试！");
							}
						}
					});
				}
			});
		});
	</script>
</body>
</html>